package com.commodity.Service.orderServiceImp;

import com.commodity.Dao.OrderDao;
import com.commodity.Dao.orderDaoImp.OrderDaoImp;
import com.commodity.Service.OrderService;
import com.commodity.entity.Order;
import com.commodity.entity.OrderSearchBean;
import com.commodity.utils.BeanFactory;
import com.commodity.utils.PaginateInfo;

import java.util.List;

public class OrderServiceImp implements OrderService {
    private final OrderDao orderDao = BeanFactory.getInstance(OrderDaoImp.class);

    @Override
    public List<Order> findAll(OrderSearchBean osb, PaginateInfo pi) {
        return orderDao.findAll(osb, pi);
    }

    @Override
    public boolean add(Order order) {
        return orderDao.add(order) > 0;
    }

    @Override
    public int deleteByIds(Integer[] intIds) {
        return orderDao.deleteByIds(intIds);
    }

    @Override
    public Order findById(Integer id) {
        return orderDao.findById(id);
    }

    @Override
    public boolean update(Order order) {
        return orderDao.update(order) > 0;
    }

    @Override
    public List<Order> findByCommodityId(String commodityIdFromCommodity, PaginateInfo pi) {
        return orderDao.findByCommodityId(commodityIdFromCommodity,pi);
    }
}
